<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="../bootstrap/css/bootstrap.min.css">
    <style>
        body {
            background-repeat: no-repeat;
            background-size: 100% auto;

        }
    </style>
</head>
<body>
<h1 style="margin-left: 150px;margin-bottom: 30px">添加售货单</h1>
<div id="addOrderForm-div" >
    <form id="addOrderForm-form" class="form-group">
        <div class="input-group mb-3" style="width: 450px">
            <label for="XHOrderDate" style="width: 140px;text-align: center;">售货订单日期:</label>
            <input type="datetime-local" name="XHOrderDate" class="form-control" id="XHOrderDate">
        </div>
        <div class="input-group mb-3" style="width: 450px">
            <label for="GDDate" style="width: 140px;text-align: center;">取货日期:</label>
            <input type="datetime-local" name="GDDate" class="form-control" id="GDDate">
        </div>
        <div class="input-group mb-3" style="width: 450px">
            <label for="GDAddress" style="width: 140px;text-align: center;">取货地点:</label>
            <input type="text" name="GDAddress" class="form-control" id="GDAddress">
        </div>
        <div class="input-group mb-3" style="width: 450px">
            <label for="RevCurrencyModeNo" style="width: 140px;text-align: center;">收款方式:</label>
            <select class="form-control" name="RevCurrencyModeNo" id="RevCurrencyModeNo">
                <option value="">请选择</option>
                <option value="1">现金</option>
                <option value="2">支付宝</option>
                <option value="3">微信</option>
            </select>
        </div>
        <div class="input-group mb-3" style="width: 450px">
            <label for="RevCurrencyLastDate" style="width: 140px;text-align: center;">收款最迟日期:</label>
            <input type="datetime-local" name="RevCurrencyLastDate" class="form-control" id="RevCurrencyLastDate">
        </div>
        <div class="input-group mb-3" style="width: 450px">
            <label for="CurrencyNo" style="width: 140px;text-align: center;">货币种类:</label>
            <select class="form-control" name="CurrencyNo" id="CurrencyNo">
                <option value="">请选择</option>
                <option value="1">人民币</option>
                <option value="2">美元</option>
                <option value="3">欧元</option>
                <option value="4">日元</option>
                <option value="5">韩币</option>
                <option value="6">港币</option>
                <option value="7">英镑</option>
            </select>
        </div>
        <div class="input-group mb-3" style="width: 450px">
            <label for="PrePayCurrency" style="width: 140px;text-align: center;">预付金额:</label>
            <input type="text" name="PrePayCurrency" class="form-control" id="PrePayCurrency">
        </div>
        <div class="input-group mb-3" style="width: 450px">
            <label for="GoodsSumCurrency" style="width: 140px;text-align: center;">货物总额:</label>
            <input type="text" name="GoodsSumCurrency" class="form-control" id="GoodsSumCurrency">
        </div>
        <div class="input-group mb-3" style="width: 450px">
            <label for="TaxSumCurrency" style="width: 140px;text-align: center;">税率总额:</label>
            <input type="text" name="TaxSumCurrency" class="form-control" id="TaxSumCurrency">
        </div>
        <div class="input-group mb-3" style="width: 450px">
            <label for="CreditCurrency" style="width: 140px;text-align: center;">赊欠金额:</label>
            <input type="text" name="CreditCurrency" class="form-control" id="CreditCurrency">
        </div>
        <div class="input-group mb-3" style="width: 450px">
            <label for="AddtionalCurrency" style="width: 140px;text-align: center;">运调费用:</label>
            <input type="text" name="AddtionalCurrency" class="form-control" id="AddtionalCurrency">
        </div>
        <div class="input-group mb-3" style="width: 450px;padding-left: 65px;">
            审核：
            <label class="radio-inline" style="width: 140px;text-align: center;">
                <input type="radio" name="isCheck" value="1">通过
            </label>
            <label class="radio-inline" style="width: 140px;text-align: center;">
                <input type="radio" name="isCheck" value="0">不通过
            </label>
        </div>
        <div class="input-group mb-3" style="width: 450px">
            <label for="CheckRes" style="width: 140px;text-align: center;">审核结果:</label>
            <input type="text" name="CheckRes" class="form-control" id="CheckRes">
        </div>
        <div class="input-group mb-3" style="width: 450px;padding-left: 35px;">
            收款收据：
            <label class="radio-inline" style="width: 140px;text-align: center;">
                <input type="radio" name="RecCurrencyRcept" value="1">是
            </label>
            <label class="radio-inline" style="width: 140px;text-align: center;">
                <input type="radio" name="RecCurrencyRcept" value="0">否
            </label>
        </div>
        <div class="input-group mb-3" style="width: 450px">
            <label style="width: 140px;text-align: center;">客户信息:</label>
            <select class="form-control" name="CustomerNo" >
                <option value="">请选择</option>
                <option v-for="cu in list1" :value="cu.customerNo">{{ cu.companyName }}</option>
            </select>
        </div>
        <div class="input-group mb-3" style="width: 450px">
            <label for="GoodsClassCounts" style="width: 140px;text-align: center;">货物种类数:</label>
            <input type="number" name="GoodsClassCounts" class="form-control" id="GoodsClassCounts">
        </div>
        <div class="input-group mb-3" style="width: 450px">
            <label for="SumProfitCurrency" style="width: 140px;text-align: center;">总净高额:</label>
            <input type="text" name="SumProfitCurrency" class="form-control" id="SumProfitCurrency">
        </div>
        <div class="input-group mb-3" style="width: 450px">
            <label for="ItemsQty" style="width: 140px;text-align: center;">订货数量:</label>
            <input type="text" name="ItemsQty" class="form-control" id="ItemsQty">
        </div>
        <div class="input-group mb-3" style="width: 450px">
            <label for="ItemsPrice" style="width: 140px;text-align: center;">订货单价:</label>
            <input type="text" name="ItemsPrice" class="form-control" id="ItemsPrice">
        </div>
        <div class="input-group mb-3" style="width: 450px">
            <label style="width: 140px;text-align: center;">物质明细表编号:</label>
            <select class="form-control" name="ItemsInfoNo">
                <option value="">请选择</option>
                <option v-for="Mi in list2"  :value="Mi.itemsInfoNo">{{ Mi.itemsName }}</option>
            </select>
        </div>
        <div class="input-group mb-3" style="width: 450px">
            <label style="width: 140px;text-align: center;">物质价格表编号:</label>
            <select class="form-control" name="ItemsNo">
                <option value="">请选择</option>
                <option v-for="Mp in list3" :value="Mp.itemsNo">{{ Mp.itemsName }}</option>
            </select>
        </div>

        <div class="input-group mb-3" style="width: 450px;margin-top: 30px">
            <button type="button" id="submit-btn" class="btn btn-primary"
                    style="margin-left: 150px; margin-right: 100px" @click="addOrderForm()">添加
            </button>
            <button type="button" class="btn btn-danger" @click="returncustomerlist()">返回</button>
        </div>
    </form>
</div>
<script type="text/javascript" src="../bootstrap/jquery3.6.js"></script>
<script type="text/javascript" src="../bootstrap/js/bootstrap.bundle.min.js"></script>
<script type="text/javascript" src="../bootstrap/vue.js"></script>
<script>
    let list1;
    let list2;
    let list3;

    $(function (){
        list1=Ajax1();
        list2=Ajax2();
        list3=Ajax3();
        let app = new Vue({
            el: "#addOrderForm-div",
            data:{
                list1:list1.list,
                list2:list2.list,
                list3:list3.list,
            },
            methods: {
                addOrderForm:function (){
                    $.ajax({
                        type:"post",
                        url:"../OrderForm/addOrderForm",
                        data:$("#addOrderForm-form").serialize(),
                        dataType:"json",
                        success:function (data){
                            if (data.message == "添加成功") {
                                location.href = "orderform_list.html";
                            }
                        }
                    })

                },
                returncustomerlist: function() {
                    location.href = "orderform_list.html";
                }
            }
        })
    })

    //首先查询公司存在那些客户
    function Ajax1(){
        let list1=[]
        $.ajax({
            type: "post",
            url: "../Customer/selCustomerNo",
            dataType: "json",
            async: false,
            success: function (json) {
                list1=json;
            }
        });
        return list1;
    }

    function Ajax2(){
        //首先查询公司存在那些物质明细
        let list2=[]
        $.ajax({
            type: "post",
            url: "../Matter/selMatterInfoItemsInfoNo",
            dataType: "json",
            async: false,
            success: function (json) {
                list2=json;
                console.log(list2);
            }
        });
        return list2;
    }

    function Ajax3(){
        let list3=[]
        $.ajax({
            type: "post",
            url: "../Matter/selMatterPriceItemsNo",
            dataType: "json",
            async: false,
            success: function (json) {
                list3=json;
            }
        })
        return list3;
    }


</script>
</body>
</html>